﻿/*
Copyright (c) 2009, Digiflare Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Digiflare nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Sharpmark.MarkTweet.Services.Twitter
{
    [ServiceContract]
    public interface ITwitterClient
    {
        #region Status Methods

        /// <summary>
        /// Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "/statuses/public_timeline.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses PublicTimeline();

        /// <summary>
        /// Returns the 20 most recent statuses posted by the authenticating user and that user's friends. 
        /// This is the equivalent of /home on the Web
        /// </summary>
        /// <returns></returns>
        [OperationContract(Name = "FriendsTimeline")]
        [WebGet(UriTemplate = "/statuses/friends_timeline.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses FriendsTimeline();

        /// <summary>
        /// Returns the 20 most recent statuses starting but not including the status id specified
        /// </summary>
        /// <param name="sinceId"></param>
        /// <returns></returns>
        [OperationContract(Name = "FriendsTimelineSince")]
        [WebGet(UriTemplate = "/statuses/friends_timeline.json?since_id={sinceId}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses FriendsTimelineSince(string sinceId);

        /// <summary>
        /// Returns the 20 most recent statuses older than the specified id
        /// </summary>
        /// <param name="maxId"></param>
        /// <returns></returns>
        [OperationContract(Name = "FriendsTimelineUntil")]
        [WebGet(UriTemplate = "/statuses/friends_timeline.json?max_id={maxId}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses FriendsTimelineUntil(string maxId);

        /// <summary>
        /// Returns the 20 most recent statuses posted from the authenticating user.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "/statuses/user_timeline.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses UserTimeline();

        /// <summary>
        /// Returns the 20 most recent statuses posted from the specified user
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "/statuses/user_timeline.json?id={id}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses UserTimelineById(string id);

        /// <summary>
        /// Returns a single status specified by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        [WebGet(UriTemplate = "/statuses/show/{id}.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status ShowStatus(string id);

        /// <summary>
        /// Updates the authenticating user's status
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        [OperationContract(Name = "Update")]
        [WebInvoke(UriTemplate = "/statuses/update.json?status={status}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status Update(string status);

        /// <summary>
        /// Updates the authenticating user's status
        /// </summary>
        /// <param name="status"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        [OperationContract(Name = "UpdateWithSource")]
        [WebInvoke(UriTemplate = "/statuses/update.json?status={status}&source={source}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status UpdateWithSource(string status, string source);

        /// <summary>
        /// Updates posted in reply to the specified status id
        /// </summary>
        /// <param name="status"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract(Name = "ReplyUpdate")]
        [WebInvoke(UriTemplate = "/statuses/update.json?status={status}&in_reply_to_status_id={id}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status Update(string status, string id);

        /// <summary>
        /// Updates posted in reply to the specific status id with source
        /// </summary>
        /// <param name="status"></param>
        /// <param name="id"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        [OperationContract(Name = "ReplyUpdateWithSource")]
        [WebInvoke(UriTemplate = "/statuses/update.json?status={status}&in_reply_to_status_id={id}&source={source}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status UpdateWithSource(string status, string id, string source);

        /// <summary>
        /// Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user.
        /// </summary>
        /// <returns></returns>
        [OperationContract(Name = "Replies")]
        [WebGet(UriTemplate = "/statuses/replies.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses Replies();

        /// <summary>
        /// Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user.
        /// </summary>
        /// <returns></returns>
        [OperationContract(Name = "RepliesSince")]
        [WebGet(UriTemplate = "/statuses/replies.json?since_id={sinceId}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Statuses Replies(string sinceId);


        /// <summary>
        /// Destroys the status specified by the required ID parameter.  The authenticating user must be the author of the specified status.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        [WebInvoke(UriTemplate = "/statuses/destroy/{id}.json",
            Method = "DELETE",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Status DestroyStatus(string id);

        #endregion

        #region User Methods

        [OperationContract(Name = "Friends")]
        [WebGet(UriTemplate = "/statuses/friends.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Users Friends();

        [OperationContract(Name = "FriendsById")]
        [WebGet(UriTemplate = "/statuses/friends/{id}.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Users Friends(string id);

        [OperationContract(Name = "Followers")]
        [WebGet(UriTemplate = "/statuses/followers.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Users Followers();

        [OperationContract(Name = "FollowersById")]
        [WebGet(UriTemplate = "/statuses/followers/{id}.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        Users Followers(string id);

        [OperationContract]
        [WebGet(UriTemplate = "/users/show/{id}.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        User ShowUser(string id);

        #endregion

        #region Direct Message Methods

        [OperationContract(Name = "DirectMessages")]
        [WebGet(UriTemplate = "/direct_messages.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        DirectMessages DirectMessages();

        [OperationContract(Name = "DirectMessagesSince)")]
        [WebGet(UriTemplate = "/direct_messages.json?since_id={sinceId}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        DirectMessages DirectMessages(string sinceId);

        [OperationContract]
        [WebGet(UriTemplate = "/direct_messages/sent.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        DirectMessages Sent();

        [OperationContract]
        [WebInvoke(UriTemplate = "/direct_messages/new.json?user={user}&text={text}",
            Method = "POST",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        DirectMessage New(string user, string text);

        [OperationContract]
        [WebInvoke(UriTemplate = "/direct_messages/destroy/{id}.json",
            Method = "DELETE",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        DirectMessage DestroyDirectMessage(string id);
        #endregion

        #region Friendship Methods
        #endregion

        #region Account Methods

        [OperationContract]
        [WebGet(UriTemplate = "/account/verify_credentials.json",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        User VerifyCrednetials();

        #endregion
    }
}
